package com.example.shop_2208.net

import com.example.shop_2208.entity.*
import io.reactivex.Observable
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Path
import retrofit2.http.Query

/**
 * 接口  网络请求的所有接口
 */
interface ApiServer {
    @POST(Const.LOGIN_URL)
    fun login1(@Body param: ParamLogin): Observable<UserEntityResult>

    //协程方式调用
    @POST(Const.LOGIN_URL)
    suspend fun login(@Body param: ParamLogin): UserEntityResult

    @POST(Const.REGISTER_URL)
    suspend fun register(@Body param: ParamRegister): UserEntityResult

    @GET(Const.BANNER_URL)
    suspend fun banner(): BannerEntityResult

    @GET(Const.CATEGORY_URL)
    suspend fun category(): CategoryEntityResult
    @GET(Const.GOODS_URL)
    suspend fun goods(
        @Query("category_id") category_id: Int,
        @Query("currentPage") currentPage: Int,
        @Query("pageSize") pageSize: Int
    ):GoodsEntityResult
    @GET(Const.DETAIL_URL)
    suspend fun detail(@Query("goods_id")goods_id :Int):DetailEntityResult

    @POST(Const.ADDCAR_URL)
    suspend fun addCar(@Body body:ParamAddcar):AddCarEntityResult
    @GET(Const.SELECTCAR_URL)
    suspend fun selectCar():CarEntityResult
    @POST(Const.DELETECAR_URL)
    suspend fun deleteCar(@Body param:ParamDeleteCar):AddCarEntityResult
    @Multipart
    @POST(Const.UPDATE_URL)
    suspend fun updateIcon(@Part part: MultipartBody.Part):AddCarEntityResult
    @GET(Const.GETCOMMENT_URL)
    suspend fun getComment():CommentEnityResult
    @GET(Const.GETCHILDCOMMENT_URL)
    suspend fun getChildComment(@Query("rootId") rootId:Int):CommentEnityResult
    @POST(Const.COMMENT_URL)
    suspend fun comment(@Body param:ParamComment):CommentEnityResult

}